<template>
  <div>
    <div class="myDiv">
      <img :src="imgUrl" alt="" />
      <p @click="btn" :style="{ backgroundColor: colorStr }">{{ dogName }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: '',
  components: {},
  props: ['imgUrl', 'dogName'],
  data() {
    return {
      colorStr: '',
    }
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    btn() {
      this.colorStr = `rgb(${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)})`,
      this.$emit('love',this.dogName)
    },
  },
}
</script>

<style scoped>
.myDiv {
  width: 200px;
  border: 1px solid black;
  text-align: center;
  float: left;
  margin-right: 40px;
}

.myDiv img {
  width: 100%;
  height: 200px;
}
</style>
